import socket, sys

host = sys.argv[1]
textport = sys.argv[2]

s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
try:
	port = int(textport)
except ValueError:
	# That didn't work.Look it up instead.
	port = socket.getservbyname(textport, 'udp')

s.connect((host, port))
print "Enter data to transmit: "
data = sys.stdin.readline().strip()
s.sendall(data)
print "Looking for replies; Press Ctrl-C or Ctrl-break to stop"

while 1:
	buf = s.recv(2048)
	if not len(buf):
		break
	sys.stdout.write(buf)